-
Notifications
You must be signed in to change notification settings - Fork 148
Speedup RNG copy in non-mutable RVs #1721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Speedup RNG copy in non-mutable RVs #1721
Conversation
|
Also make use of the new helper here:
|
|
@ricardoV94 Thank you for the checks. I have made the corrections |
tests/tensor/random/test_utils.py
Outdated
| @pytest.mark.performance | ||
| def test_custom_rng_deepcopy_faster_than_deepcopy(): | ||
| rng = np.random.default_rng() | ||
|
|
||
| t_dp = timeit.timeit(lambda: deepcopy(rng), number=2000) | ||
| t_fc = timeit.timeit(lambda: custom_rng_deepcopy(rng), number=2000) | ||
|
|
||
| # Fast copy should be at least 20% faster | ||
| assert t_fc < t_dp * 0.8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need, and we have a different framework for benchmarking
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I didn't know about the benchmarking framework
Description
This PR improves how RandomVariable copies RNG state when inplace=False.
Related Issue
Checklist
Type of change
@ricardoV94 I think this closes the #1708 using the code you provided, I just added some tests